#ifndef UC_SEG_RESEND_MANAGER_H_
#define UC_SEG_RESEND_MANAGER_H_


#define BLOCK_RESEND_FLAG 1
#define BLOCK_UNRESEND_FLAG 0

typedef struct segment_resend_manage
{
    void *parameter;
    void * resend_seg_timer;
    int timeout;
    unsigned char *mask;
    unsigned short mask_bit_num;// is all num
    unsigned char page_num;
    unsigned char na;
    unsigned int dest_addr;
}t_seg_resend_manager;

/*
Resend strategy:

1.  After the transmission is completed, initialize the retransmission resource management, and release the resources when the timer expires

2.  Reset timer every time a retransmission message is received

3.  After receiving a packet loss request, set the resend identifier.

4.  After receiving a packet loss request every time, start a loop to read the duplicate identifier and repeat the packet loss
*/

void package_clear_resend_flag(char *mask, unsigned short loss_number);

void package_set_resend_flag(char *mask, unsigned short loss_number);

unsigned char package_get_resend_flag(char *mask, unsigned short loss_number);

//void packege_reset_timer(void* timer_handle, int timeout);

t_seg_resend_manager* packege_init_resend_seg_manager(void (*timer_func)(void* parameter), 
    void *parameter, 
    int timeout, 
    unsigned int dest_addr,
    unsigned char page_num,
    int all_num);

t_seg_resend_manager* packege_get_resend_seg_manager(void);

int packege_clear_resend_seg_manager(t_seg_resend_manager *seg_resend_manage);

#endif
